@extends('layouts.app')

@section('content')
<style type="text/css">
	.tongjitu_tb tr {
		height: 45px;
	}
	
	.dizhi {
		width: 320px;
	}
	.dizhi select {
		width: 150px;
		display: inline-block;
	}
	.sousou {
		width: 100%;
		margin-top: 15px;
	}
	.paiming_color {
		width: 32px;
		height: 32px;
		display: inline-block;
		background: url("http://nb.yntosite.com/images/hui.png");
		vertical-align: middle;
		margin-right: 10px;
	}
	.paiming_color1 {
		background: url("http://nb.yntosite.com/images/jin.png");
	}
	.paiming_color2 {
		background: url("http://nb.yntosite.com/images/yin.png");
	}
	.paiming_color3 {
		background: url("http://nb.yntosite.com/images/tong.png");
	}
	.paiming_font {
		font-size: 14px;
		line-height: 45px;
		
	}
	.btn_color {
		    border-color: #adadad;
	        background-color: #ebebeb
	}
</style>
<div class="main-content">
    <div class="btn-toolbar list-toolbar">
    	
        <div class="form-all mg_t100">
        	<!-- <a href="javascript:history.back(-1);" class="easyui-linkbutton" data-options="iconCls:'icon-back'">返回</a> -->
        	<div class="clearfix sousou">
        		<div class="dizhi pull-left">
        			<select class="form-control" id="time_select">
	        			<option value="zhou" selected="selected">周</option>
	        			<option value="yue">月</option>
	        			<option value="nian">年</option>
	        		</select>
        		</div>
        		<div class="chart_btns pull-right">
	             	<button class="btn btn-default " id="zonghe">综合排行</button>
	             	<button class="btn btn-default btn_color" id="qyjc">企业检查数</button>
	             	<button class="btn btn-default " id="yrjc">人员检查数</button>
	             	<button class="btn btn-default " id="ajfk">案件反馈回复数</button>
	             	<button class="btn btn-default " id="jyfk">建议反馈回复数</button>
         		</div>
        	</div>
        	
            
          <div id="div_print">
		    <table class="table-form table-border w mg-auto tongjitu_tb" style="margin-top: 30px;">
					<thead>
						<tr>
							<th colspan="11">民警排名统计表</th>
						</tr>
					</thead>
					<tbody>
						<tr class="thead">
							<td>名次</td>
							<td>姓名</td>
							<td>数量</td>
						</tr>
						<!--<tr>
							<td>
								<span class="paiming_color paiming_color1"></span>
								<strong class="paiming_font">第1名</strong>
							</td>
							<td>荆州宾馆</td>
						</tr>-->
						
					</tbody>
				</table>

		</div>             

          </div>
    </div>
</div>
 <script type="text/javascript">
    	
				
  </script>
<script type="text/javascript">
	
	var cityId = '0' ;
	function load_city_data_from_menu(id){
			console.log(id);
			cityId = id;
			times = $("#time_select").val();
			paiming(cityId,times,type)
			console.log(cityId+","+times+","+type);
		}
		function load_area_data_from_menu(id){
			console.log(id);
			cityId = id;
			times = $("#time_select").val();
			paiming(cityId,times,type)
			console.log(cityId+","+times+","+type);
		}
		function load_org_data_from_menu(id){
			console.log(id); 
			cityId = id;
			times = $("#time_select").val();
			paiming(cityId,times,type)
			console.log(cityId+","+times+","+type);
		}
	
	
	
	
	var type ='1';
	var times ='zhou';
	var daTa ;
	 $("#time_select").change(function(){
	     times = $(this).val();
	    console.log(cityId+","+times+","+type);
	     paiming(cityId,times,type)
	 });
	
	$("#zonghe").click(function(){
		$(this).addClass("btn_color").siblings().removeClass("btn_color");
		 times = $("#time_select").val();
		 type = '0'
		 console.log(cityId+","+times+","+type);
		paiming(cityId,times,type)
	})
	
	$("#qyjc").click(function(){
		$(this).addClass("btn_color").siblings().removeClass("btn_color");
		 times = $("#time_select").val();
		 type = '1'
		 console.log(cityId+","+times+","+type);
		paiming(cityId,times,type)
	})
	
	$("#yrjc").click(function(){
		$(this).addClass("btn_color").siblings().removeClass("btn_color");
		 times = $("#time_select").val();
		 type = '2'
		console.log(cityId+","+times+","+type);
		paiming(cityId,times,type)
	})
	
	$("#ajfk").click(function(){
		$(this).addClass("btn_color").siblings().removeClass("btn_color");
		 times = $("#time_select").val();
		 type = '3'
		console.log(cityId+","+times+","+type);
		paiming(cityId,times,type)
	})
	
	$("#jyfk").click(function(){
		$(this).addClass("btn_color").siblings().removeClass("btn_color");
		 times = $("#time_select").val();
		 type = '4'
		console.log(cityId+","+times+","+type);
		paiming(cityId,times,type)
	})
	
		paiming('0','zhou','1')
		
		function paiming(cityId,times,type){
     	$.ajax({
    	 	type:"POST",
    	 	url:"{{url('admin/mjph/index')}}",
    	 	async:true,
    	 	data: {'city':cityId,'times':times,'type':type,'_token':'{{csrf_token()}}'},
    	    dateType: 'json',
    	    success : function(data){
    	    	var obj = {};
    	        var obj = jQuery.parseJSON(data);
    	        console.log(obj);
    	        daTa = obj.message.jc_num;
    	        console.log(daTa);
    	        console.log(cityId+","+times+","+type);
    	        		if(daTa.length == 0){
	        				 $(".tongjitu_tb .thead").nextAll().remove();
		    	        	 var inner_data = '<tr>'+
												 '<td colspan="3">暂无数据</td>'+
											 '</tr>'
								      	  $(".tongjitu_tb tr").eq(-1).after(inner_data);		
				      	  }else{
				      	  		 $(".tongjitu_tb .thead").nextAll().remove();
				      	  		 for(var i =0;i<daTa.length;i++){
    	        	 	 			 console.log(daTa[i].rank)
		        	 	 	 		var inner_data = '<tr>'+
													 '<td><span class="paiming_color paiming_color'+daTa[i].rank+'"></span>'+
													 	  '<strong class="paiming_font">第'+daTa[i].rank+'名</strong></td>'+
													
													 '<td>'+daTa[i].name+'</td>'+
													 '<td>'+daTa[i].count+'</td>'+
											 	'</tr>'
								 	 $(".tongjitu_tb tr").eq(-1).after(inner_data);			 
    	        	 	 		
    	        				 }
				      	  }
    	       /* if(daTa.rank.length == 0){
    	        	 $(".tongjitu_tb .thead").nextAll().remove();
    	        	 var inner_data = '<tr>'+
										 '<td colspan="3">暂无数据</td>'+
									 '</tr>'
						      	  $(".tongjitu_tb tr").eq(-1).after(inner_data);		
    	        }else{
    	        	 $(".tongjitu_tb .thead").nextAll().remove();
    	        	 for(var i =0;i<daTa.rank.length;i++){
    	        	 	 	 console.log(daTa.rank[i].rank)
	        	 	 	 		var inner_data = '<tr>'+
												 '<td><span class="paiming_color paiming_color'+daTa.rank[i].rank+'"></span>'+
												 	  '<strong class="paiming_font">第'+daTa.rank[i].rank+'名</strong></td>'+
												
												 '<td>'+daTa.rank[i].name+'</td>'+
												 '<td>'+daTa.rank[i].count+'</td>'+
										 	'</tr>'
							 	 $(".tongjitu_tb tr").eq(-1).after(inner_data);			 
    	        	 	 		
    	        	 }
    	        }*/
    	       
    	    }
    	   
    	 });
 	  }
 	  
 	 
</script>

@stop
